<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>点击元素，展开或隐藏一个元素</title>
    <link rel="stylesheet" type="text/css" href="normalize.css">
    <style>
        .ticket-arrow-up, .ticket-arrow-down {
            float: right;
            width: 1.1rem;
            margin-top: 0.6rem;
            margin-right: 0.5rem;
            height: 15px;
            /*这个是箭头上下合在一张的图片*/
            background-image: url(arrow.jpg);
            background-size: 15px;
            background-repeat: no-repeat;
            background-position: left top;
        }

        .ticket-arrow-down {
            background-position: left bottom;
        }
    </style>
    <script src="jquery-2.1.4.min.js"></script>
    <script>

        //引入了jquery
        $(document).ready(function () {
//景区详情中门票的切换效果以及弹窗（第一种方法，背景图的时候，添加togglClass()）
            $('.ticket-arrow-up').click(function () {
//toggleClass() 方法对添加和移除被选元素的类进行切换。
//这个class有的背景图进行了定位，变成了收起的箭头
                $(this).toggleClass('ticket-arrow-down');
//这个兄弟元素view-ticket-c在显示与隐藏进行切换。
                $(this).siblings('.view-ticket-c').toggle();
            });
//（第二种方法，前景图判断src，来通过src来改变）
//这个html结构是的下拉收起的图标是前景图
            $(".insurance-details").click(function (event) {
//点击出现的内容，显示或隐藏出现的内容
                $(this).siblings(".insurance-explain").toggle();
//下拉收起的图标是前景图,通过src来判断，进行切换
                if ($(this).children().attr("src") == "images/drop_down_icon.png") {
                    $(this).children().attr("src", "images/drop_up_icon.png");
                } else {
                    $(this).children().attr("src", "images/drop_down_icon.png");
                }
            });
//（第三种方法，背景图下拉收起的图标放在一张图中，通过css定位来判断）
            $(".on-off").click(function (event) {
//点击出现的内容，显示或隐藏出现的内容
                $("#insur-content").toggle();
//下拉收起的图标是背景图,背景图的定位来判断
//背景图如果定位是左边，顶部
                if ($(this).css("background-position") == "0% 0%") {
//那么把背景图改为定位是右边，顶部
                    $(this).css("background-position", "right top");
                } else {
                    $(this).css("background-position", "left top");
                }
            });
        });
        //（第四种方法，通过添加状态）
    </script>
</head>
<body>
<div class="view-details-ticket">
    <!-- 这个是下拉箭头的元素 -->
    <span class="ticket-arrow-up"></span>
    <h3 class="view-ticket-title">单门票</h3>
    <div class="view-ticket-c">
        <p class="view-ticket-list">峨眉山成人票</p>
        <p class="view-ticket-price">￥68<span class="ticket-explain">票型说明</span></p>
    </div>
    <div>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
        <p>d;ljasdlkf;lkj,a;lskdjf lakfsj</p>
    </div>
</div>

</body>
</html>